#include "date.h"
#include "widget.h"
#include <QDebug>

void Widget::updateParkingStatus(int no, const QString& plate)
{
    for (auto& spot : m_parkingSpots)
    {
        if (spot->getNo() == no) // 注意这里直接访问了No，实际中应使用一个getter函数或确保No的访问性
        {
            spot->setLicensePlateNumber(plate);
            spot->setOccupied(OCCUPIED);
            qDebug() << "Car parked in spot with No:" << no << "with license plate:" << plate;
            // 更新UI或其他需要的操作
            updateButtonColorForSpot(spot);
            updateWidgetColorForSpot(spot);
            break;
        }
    }
}

void Widget::updateParkingStatus(int no, const QString& license_plate_number, const QString& last_entry_time, const QString& time, int expense)
{
    for (auto& spot : m_parkingSpots)
    {
        if (spot->getNo() == no)
        {
            spot->setLicensePlateNumber(license_plate_number);
            spot->setOccupied(OCCUPIED);
            spot->setLastEntryTime(last_entry_time);
            spot->setCurrentTime(time);
            // 假设ParkingDate类中有一个设置费用的函数
            spot->setExpense(expense);
            qDebug() << "Car parked in spot with No:" << no << "with license plate:" << license_plate_number
                     << "at:" << last_entry_time << "with expense:" << expense;
            updateButtonColorForSpot(spot);
            updateWidgetColorForSpot(spot);
            break;
        }
    }
}


